package com.gy.niuer.controller;


import com.gy.niuer.domain.*;
import com.gy.niuer.service.AppointmentService;
import com.gy.niuer.service.PatientService;
import com.gy.niuer.service.SchedulingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/appoint")
public class AppointController {

    @Autowired
    PatientService patientService;

    @Autowired
    SchedulingService schedulingService;

    @Autowired
    AppointmentService appointmentService;


    @PostMapping("/{schedulId}")
    public boolean addAppoint(@PathVariable int schedulId,@RequestBody Appointment appointment){

        return appointmentService.addAppoint(schedulId,appointment);
    }

    @PostMapping("/cancelAppoint/{id}")
    public boolean cancelAppoint(@PathVariable Integer id){
        Appointment appointment = new Appointment();
        appointment.setId(id);
        boolean b = appointmentService.deleteAppoint(appointment);
        return b;
    }

    @GetMapping("selectAppointmentById/{id}")
    public List<Appointment> selectAppointment(@PathVariable int id){
        List<Appointment> appointments = appointmentService.selectById(id);
        return appointments;
    }

    @GetMapping("getAllAppoint/{id}")
    public List<Appointment> getAllAppointment(@PathVariable int id){

        return appointmentService.getAllAppoint(id);
    }
}
